package com.example.recruitment_website.dto;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

@Transactional
@Repository
public interface HeadlinesBriefRepository extends JpaRepository<HeadlinesBriefDto,Integer> {

    @Query(value = "select id,title,img_url,date,type from article h order by h.id desc",nativeQuery = true)
    List<HeadlinesBriefDto> findHeadlinesList();

    @Query(value = "select id,title,img_url,date,type from article h where h.type = ?1 order by h.id desc",nativeQuery = true)
    List<HeadlinesBriefDto> findListByType(Integer type);

    @Query(value = "select id,title,img_url,date,type from article where title like %?1%",nativeQuery = true)
    List<HeadlinesBriefDto> searchArticleByKey(String key);

}
